﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using SqlSugarWebApi.DataContext.Context;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SqlSugarWebApi.DataContext.AutoMapper
{
    public static class IAutoDBContextConnection
    {
        public static IServiceCollection AutoDBContextConnection(this IServiceCollection services, IConfiguration config)
        {
            return services.AddScoped<SqlSugarClient>(s =>
              {
                  SqlSugarClient sqlSugar = new DbContext().initDbContext(config, "SqlSugarConnection");
                  return sqlSugar;
              });
        }
    }
}
